package com.hzhq.contract.convert;

import com.hzhq.contract.bean.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import com.hzhq.contract.bean.dto.UserDTO;
import com.hzhq.contract.bean.entity.User;

/**
 * @author hzhq
 * @create 2021/4/10 4:44 下午
 * @email hzhq1255@163.com
 */
@Mapper
public interface UserConvertBasic {


    UserConvertBasic INSTANCE = Mappers.getMapper(UserConvertBasic.class);


    UserDTO poToDto(User source);

    User dtoToPo(UserDTO source);

    @Mappings({
            @Mapping(target = "userId", expression = "java(com.hzhq.contract.util.ConvertUtil.objectIdToString(source.getUserId()))"),
    })
    UserVO dtoToVo(UserDTO source);

    @Mappings({
            @Mapping(target = "userId", expression = "java(com.hzhq.contract.util.ConvertUtil.stringToObjectId(source.getUserId()))")
    })
    UserDTO voToDto(UserVO source);

}
